package Navigator.Systemer;

import Worker.WorkerDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "updateWorkerServlet")
public class updateWorkerServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
         String workerNo=request.getParameter("workerNo");
         String workerName=request.getParameter("workerName");
         String sex=request.getParameter("sex");
         String workPas=request.getParameter("WorkPas");
         String post=request.getParameter("post");
         WorkerDao workerDao=new WorkerDao();
         int row=workerDao.updateWorker(workerNo,workerName,sex,workPas,post);
         if(row>0){
             response.sendRedirect("/SystemerNav/WorkerMangeMent.jsp?workerNo="+workerNo);
         }else {
             PrintWriter out=response.getWriter();
             out.println("修改失败");
         }
    }
}
